<?php $ventes = $this->object ?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span3">
            <?php echo $this->partial('_menu.phtml');?>
            <!--/.well -->
        </div>
        <div class="span9">
            <div class="wrap">
                <div id="main-content">
                    <form class="form-horizontal" name="frm" action="<?php echo $this->baseUrl('admin/ventes/save') ?>" method="post" enctype="multipart/form-data">
                        <input type="hidden" name="id" value="<?php echo $this->request()->getParam('id') ?>" />
                        <h3>Edition</h3>
                    	<ul class="nav nav-tabs" id="edit-form-tab">
                    		<li class="frm1 active"><a href="#frm1">Généralités</a></li>
                    		<li class="frm2"><a href="#frm2">Description</a></li>
                    		<li class="frm3"><a href="#frm3">Couvertures</a></li>
                    		<li class="frm4"><a href="#frm4">Horaire</a></li>
                    		<li class="frm5"><a href="#frm5">Expo</a></li>
                    	</ul>
                    	<div class="tab-content">
                            <div id="frm1" class="tab-pane active">
                                <?php $time = $ventes->getDtvente() ? strtotime($ventes->getDtvente()) : time() ?>
                            	<div class="control-group">
                            		<label class="control-label" for="datepicker">Date :</label>
                            		<div class="controls">
                            			<input type="text" name="data[dtvente]" id="datepicker" value="<?php echo date('d/m/Y', $time) ?>"/>
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="titre">Titre :</label>
                            		<div class="controls">
                            			<input type="text" name="data[titre]" id="titre" value="<?php echo htmlspecialchars($ventes->getTitre()) ?>" placeholder="Titre" required />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="com">Commission :</label>
                            		<div class="controls">
                            			<input type="text" name="data[com]" id="com" style="width:25px" value="<?php echo $ventes->getCom() ?>" placeholder="Commission" />%
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label">Type de vente :</label>
                            		<div class="controls">
                            			<input type="radio" name="data[type_vente]" value="bd" checked <?php if($ventes->getTypeVente() == "bd") { echo "checked"; } ?>/> BD &nbsp;
                            			<input type="radio" name="data[type_vente]" value="fg" <?php if($ventes->getTypeVente() == "fg") { echo "checked"; } ?>/> FG &nbsp;
                            			<input type="radio" name="data[type_vente]" value="obj" <?php if($ventes->getTypeVente() == "obj") { echo "checked"; } ?>/> Objets
                            		</div>
                            	</div>
                            	<?php if($this->request()->getParam('id')){ ?>
                            		<div class="control-group">
                            			<label class="control-label">Visible en ligne ?</label>
                            			<div class="controls">
                            				<input type="radio" class="radio" name="data[visible]" value="1" <?php if($ventes->getVisible() == 1) echo 'checked="checked"' ?> /> Oui
                            				<input type="radio" class="radio" name="data[visible]" value="0" <?php if($ventes->getVisible() == 0) echo 'checked="checked"' ?> /> Non
                            			</div>
                            		</div>
                            		<div class="control-group">
                            			<label class="control-label">Articles visibles en ligne ?</label>
                            			<div class="controls">
                            				<input class="radio" type="radio" value="1" name="data[articles_en_ligne]" <?php if ($ventes->getArticlesEnLigne() == 1) { echo 'checked="checked"'; } ?>> Oui
                            				<input class="radio" type="radio" value="0" name="data[articles_en_ligne]" <?php if ($ventes->getArticlesEnLigne() == 0) { echo 'checked="checked"'; } ?>> Non
                            			</div>
                            		</div>
                            	<?php } ?>
                            	<div class="control-group">
                            		<label class="control-label" for="rep_photos">Répertoires des photos :</label>
                            		<div class="controls">
                            			<input type="text" name="data[rep_photos]" id="rep_photos" value="<?php echo $ventes->getRepPhotos() ?>" placeholder="Répertoires des photos" />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="catalogue">Nom du catalogue en PDF : </label>
                            		<div class="controls">
                            			<input type="text" name="data[catalogue]" id="catalogue" value="<?php echo $ventes->getCatalogue() ?>" placeholder="Nom du catalogue en PDF" />
                            		</div>
                            	</div>
                            <?php if(!$this->request()->getParam('id')) : ?>
                            	<div class="control-group">
                            		<label class="control-label">Version papier dispo ?</label>
                            		<div class="controls">
                            			<input type="radio" name="data[cat_dispo]" value="1" checked/> Oui &nbsp;
                            			<input type="radio" name="data[cat_dispo]" value="0" /> Non
                            		</div>
                            	</div>
                            <?php else : ?>
                            	<div class="control-group">
                            		<label class="control-label">Catalogue papier dispo ?</label>
                            		<div class="controls">
                            			<input type="radio" name="data[cat_dispo]" value="1" <?php if ($ventes->getCatDispo() == 1) { echo 'checked="checked"'; } ?> /> Oui &nbsp;
                            			<input type="radio" name="data[cat_dispo]" value="0" <?php if ($ventes->getCatDispo() == 0) { echo 'checked="checked"'; } ?> /> Non
                            		</div>
                            	</div>
                            <?php endif ?>
                            	<div class="control-group">
                            		<label class="control-label" for="dtlimiteordre">Date limite ordre ?</label>
                            		<div class="controls">
                            			<input type="text" name="data[dtlimiteordre]" id="dtlimiteordre" value="<?php echo stripslashes($ventes->getDtlimiteordre()) ?>" placeholder="Date limite ordre" />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="msg_dispo_cat">Message si catalogue non dispo :</label>
                            		<div class="controls">
                            			<input type="text" name="data[msg_dispo_cat]" id="msg_dispo_cat" value="<?php echo stripslashes($ventes->getMsgDispoCat()) ?>" placeholder="Message si catalogue non dispo" />
                            		</div>
                            	</div>
                            <?php if($this->request()->getParam('id')) : ?>
                            	<div class="control-group">
                            		<label class="control-label">PDF des résultats :</label>
                            		<div class="controls">
                            			<input type="text" name="data[resultats]" value="<?php echo $ventes->getResultats() ?>" />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label">Autoriser renumérotation ?</label>
                            		<div class="controls">
                            			<input type="radio" name="data[renum]" value="1" <?php if ($ventes->getRenum() == 1) { echo 'checked="checked"'; } ?> /> Oui
                            			<input type="radio" name="data[renum]" value="0" <?php if ($ventes->getRenum() == 0) { echo 'checked="checked"'; } ?> /> Non
                            		</div>
                            	</div>
                            <?php endif ?>
                            </div>
                            <div id="frm2" class="tab-pane">
                            	<div class="editor-wrapper">
                            	    <textarea name="data[contenu]" cols="50" rows="15" id="contenu"><?php echo stripslashes($ventes->getContenu()) ?></textarea>
                        			<script type="text/javascript">
                                    CKEDITOR.replace('contenu', {});
                                    </script>
                            	</div>
                            </div>
                            <div id="frm3" class="tab-pane">
                            	<div class="control-group">
                            		<label class="control-label">Couverture liste des ventes :</label>
                            		<div class="controls">
                            		  <?php if ($ventes->getVignette() != "") { ?>
                                      	<a href="../../cover/$this->vente['vignette']" target="_blank" ><?php echo $this->vente['vignette']?></a><br />
                                        <p>Conserver cette vignette ? <input name="conserveVISmall" type="radio" value="1" checked /> Oui <input type="radio" name="conserveVISmall" value="<?php echo $this->vente['vignette'] ?>" /> Non</p>
                                        <p>Si vous voulez remplacer la vignette, veuillez sélectionner un nouveau fichier :</p>
                                      <?php
                                        }
                                      ?>
                            			<input type="file" name="userfileSmall" /> (petite image)
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label">Couverture détail vente :</label>
                            		<div class="controls">
                            		 <?php if ($ventes->getVignetteVente() != "") { ?>
                                     	<a href="../../cover/$this->vente['vignette_vente']" target="_blank"><?php echo $this->vente['vignette_vente'] ?></a><br />";
                                        <p>Conserver cette vignette ? <input name="conserveVIBig" type="radio" value="1" checked /> Oui <input type="radio" name="conserveVIBig" value="<?php echo $this->vente['vignette_vente'] ?>" /> Non</p>
                                        <p>Si vous voulez remplacer la vignette, veuillez sélectionner un nouveau fichier :</p>
                               		 <?php
                                     }
                                     ?>
                            			<input type="file" name="userfileBig" />  (grande image)
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="auteur">Auteur :</label>
                            		<div class="controls">
                            			<input type="text" name="data[auteur]" id="auteur" value="<?php echo stripslashes($ventes->getAuteur()) ?>" placeholder="Auteur" />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="photographe">Photographe :</label>
                            		<div class="controls">
                            			<input type="text" name="data[photographe]" id="photographe" value="<?php echo stripslashes($ventes->getPhotographe()) ?>" placeholder="Photographe" />
                            		</div>
                            	</div>
                            </div>
                            <div id="frm4" class="tab-pane">
                                <?php
                                    if ($this->request()->getParam('id')) {
                                        $ventesModel = new Admin_Model_Ventes();
                                        $horaires = $ventesModel->getHoraires($ventes->getPVentes());
                                    }
                                ?>
                            	<div class="control-group">
                            		<label class="control-label" for="premier">Début 1ère tranche horaire :</label>
                            		<div class="controls">
                            			<input type="text" name="data[premier]" id="premier" placeholder="Début 1ère tranche horaire" value="<?php echo $ventes->getPremier() ?>" />
                            			<?php if (isset($horaires)) : foreach($horaires as $pr) : ?>
                            			    <?php $cats = explode(",", $ventes->getCatPremier()) ?>
                            			    <p>
                            			        <input type="checkbox" name="data[cat_premier][]" value="<?php echo $pr['category_id'] ?>" <?php if (in_array($pr['category_id'], $cats)) : ?>checked<?php endif ?> />
                            			        <?php echo sprintf("%03s",$pr['min_art_num'])." -> ".sprintf("%03s",$pr['max_art_num']) . " : " . stripslashes($pr['description']) ?>
                            			    </p>
                            			<?php endforeach; endif ?>
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="second">Début 2nde tranche horaire :</label>
                            		<div class="controls">
                            			<input type="text" name="data[second]" id="second" placeholder="Début 2nde tranche horaire" value="<?php echo $ventes->getSecond() ?>" />
                            			<?php if (isset($horaires)) : foreach($horaires as $pr) : ?>
                            			    <?php $cats = explode(",", $ventes->getCatSecond()) ?>
                            			    <p>
                            			        <input type="checkbox" name="data[cat_second][]" value="<?php echo $pr['category_id'] ?>" <?php if (in_array($pr['category_id'], $cats)) : ?>checked<?php endif ?> />
                            			        <?php echo sprintf("%03s",$pr['min_art_num'])." -> ".sprintf("%03s",$pr['max_art_num']) . " : " . stripslashes($pr['description']) ?>
                            			    </p>
                            			<?php endforeach; endif ?>
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="troisieme">Début 3ème tranche horaire :</label>
                            		<div class="controls">
                            			<input type="text" name="data[troisieme]" id="troisieme" placeholder="Début 3ème tranche horaire" value="<?php echo $ventes->getTroisieme() ?>" />
                            			<?php if (isset($horaires)) : foreach($horaires as $pr) : ?>
                            			    <?php $cats = explode(",", $ventes->getCatTroisieme()) ?>
                            			    <p>
                            			        <input type="checkbox" name="data[cat_troisieme][]" value="<?php echo $pr['category_id'] ?>" <?php if (in_array($pr['category_id'], $cats)) : ?>checked<?php endif ?> />
                            			        <?php echo sprintf("%03s",$pr['min_art_num'])." -> ".sprintf("%03s",$pr['max_art_num']) . " : " . stripslashes($pr['description']) ?>
                            			    </p>
                            			<?php endforeach; endif ?>
                            		</div>
                            	</div>

                            </div>
                            <div id="frm5" class="tab-pane">
                            	<div class="editor-wrapper">
            			            <textarea name="data[expo]" cols="50" rows="15" id="resume"><?php echo stripslashes($ventes->getExpo()) ?></textarea>
        			                <script type="text/javascript">
                                    CKEDITOR.replace( 'resume', {});
                                    </script>
                        		</div>
                            </div>
                        </div>
                        <div align="center">
                        	<input class="btn btn-primary" type="submit" name="submit" value="sauver" />
                            <input type="hidden" name="p_ventes" value="<?php echo $this->vente['p_ventes']; ?>">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
    $("#datepicker").datepicker($.datepicker.regional["fr"]);
});
</script>
